# Contributor: Johannes Matheis <jomat+alpinebuild@jmt.gr>
# Maintainer: Johannes Matheis <jomat+alpinebuild@jmt.gr>
pkgname=fastd
pkgver=19
pkgrel=0
pkgdesc="Fast and Secure Tunneling Daemon"
url="https://github.com/NeoRaider/fastd/"
arch="all"
license="BSD-2-Clause AND BSD-3-Clause"
makedepends="$depends_dev cmake doxygen bison bsd-compat-headers
	linux-headers libsodium-dev libcap-dev libuecc-dev json-c-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/NeoRaider/fastd/releases/download/v$pkgver/fastd-$pkgver.tar.xz
	fastd.conf
	fastd.initd"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DENABLE_SYSTEMD=OFF \
		.
	make -C build
}

check() {
	# no testsuite
	./build/src/fastd --version
	./build/src/fastd --verify-config
}

package() {
	make -C build install DESTDIR="$pkgdir"

	install -Dm644 COPYRIGHT \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
	install -Dm644 doc/fastd.1 \
		"$pkgdir"/usr/share/man/man1/fastd.1

	install -dm700 "$pkgdir"/etc/fastd/peers/
	install -Dm600 "$srcdir"/fastd.conf \
		"$pkgdir"/etc/fastd/fastd.conf
	install -Dm755 "$srcdir"/fastd.initd \
		"$pkgdir"/etc/init.d/fastd
}

sha512sums="fc15c34214c41880449fe5f47c7577e31b61dda68eb8b3aa5a0b1ad2ab1922a3c4a92afa87a318ea30bb4579b8b0f6cee510312d895c16b3f5824bbc23523a3e  fastd-19.tar.xz
3e6c3a77f93a1e670e8f018833c499e8ec57b8240a6f472da03254ad9a7e6fed2c3459fa47b06c97e42afcfe6f0adfaaec39bce6b6a286a1ce7ef3585853b118  fastd.conf
e64b0c548cf063624ac0b632bac672c5f204586aa03aa9b06afc46f48645f1458e2400e98ee993c74aa5da3a9e86c4151e2e29c634ee59941cd81a216cea308a  fastd.initd"
